package com.yanyu.space.sys.service.test.impl;

import com.yanyu.space.common.core.bean.web.R;
import com.yanyu.space.member.bean.bo.StudentBo;
import com.yanyu.space.member.feign.IMemberClient;
import com.yanyu.space.member.feign.IMemberClient2;
import com.yanyu.space.sys.service.test.IFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.annotation.SpanTag;
import org.springframework.stereotype.Service;

/**
 * @author gz
 */
@Service
@Slf4j
public class FeignServiceImpl implements IFeignService {

    @Autowired
    private IMemberClient memberClient;
    @Autowired
    private IMemberClient2 memberClient2;

    @Override
    public void testRequestParam() {
        String param = "testRequestParam";
        log.info("请求开始, 请求参数：{}", param);
        R<String> result = memberClient.testRequestParam(param);
        log.info("响应结果：{}", result);
    }

    @Override
    public void testRequestBody() {
        StudentBo studentBo = new StudentBo();
        studentBo.setAge("1");
        studentBo.setName("2");
        log.info("请求开始, 请求参数：{}", studentBo);
        R<String> result = memberClient.testRequestBody(studentBo);
        log.info("响应结果：{}", result);
    }

    @Override
    public void testThrowFallbackFactory1() {
        String param = "testThrowFallbackFactory1";
        log.info("请求开始, 请求参数：{}", param);
        R<String> result = memberClient.testThrowFallbackFactory1(param);
        log.info("响应结果：{}", result);
    }

    @Override
    public void testThrowFallbackFactory2() {
        String param = "testThrowFallbackFactory2";
        log.info("请求开始, 请求参数：{}", param);
        R<String> result = memberClient.testThrowFallbackFactory2(param);
        log.info("响应结果：{}", result);
    }

    @Override
    public void testThrowNoFallbackFactory1() {
        String param = "testThrowNoFallbackFactory1";
        log.info("请求开始, 请求参数：{}", param);
        R<String> result = memberClient2.testThrowNoFallbackFactory1(param);
        log.info("响应结果：{}", result);
    }

    @Override
    public void testThrowNoFallbackFactory2() {
        String param = "testThrowNoFallbackFactory2";
        log.info("请求开始, 请求参数：{}", param);
        R<String> result = memberClient2.testThrowNoFallbackFactory2(param);
        log.info("响应结果：{}", result);
    }
}
